﻿using System;
using UnityEngine;
using UnityEngineInternal;

namespace Assets.Scripts.Util
{
    public class UnityResources
    {
        public static UnityEngine.Object Load(string path)
        {
            LogResource(path);
            return Resources.Load(path);
        }
        public static UnityEngine.Object Load(string path, Type systemTypeInstance)
        {
            LogResource(path);
            return Resources.Load(path, systemTypeInstance);
        }
        public static T Load<T>(string path) where T : UnityEngine.Object
        {
            LogResource(path);
            return Resources.Load<T>(path);
        }
        public static void LogResource(string path)
        {
            //Debug.LogWarning("Resources.Load:" + path);
        }

        public static T Instantiate<T>(T original, string key = "") where T : UnityEngine.Object
        {

            T objIns = GameObject.Instantiate<T>(original);
            return objIns;
        }
        [TypeInferenceRule(TypeInferenceRules.TypeOfFirstArgument)]
        public static UnityEngine.Object Instantiate(UnityEngine.Object original, Vector3 position, Quaternion rotation, string key = "")
        {

            UnityEngine.Object objIns = GameObject.Instantiate(original, position, rotation);
            return objIns;
        }
    }
}